import AudioManager from "../AudioManager";
import DataCenter from "../DataCenter";
import PopUp from "../PopUp";

const { ccclass, property } = cc._decorator;

@ccclass
export default class MyProfile extends PopUp {

    @property(cc.Label)
    highScoreLbl: cc.Label = null;

    @property(cc.Label)
    totalScoreLbl: cc.Label = null;

    @property(cc.Label)
    timeSpentLbl: cc.Label = null;

    @property(cc.Label)
    numbersOfGames: cc.Label = null;


    initUI(highScore: number,
        totalScore: number,
        time: number,
        games: number) {
        this.highScoreLbl.string = `${highScore}`;
        this.totalScoreLbl.string = `${totalScore}`;

        const seconds = `${time % 60}`.padStart(2, '0');
        const minutes = `${time % 3600 / 60 | 0}`.padStart(2, '0');
        const hours = `${time / 3600 | 0}`.padStart(2, '0');

        this.timeSpentLbl.string = `${hours}:${minutes}:${seconds}`;
        this.numbersOfGames.string = `${games}`;
    }

    onDeleteBtnClicked() {
        this.audio.playCursor();

        console.log(`CLEAR ALL RECORDS`);
        DataCenter.clearRecord();
        this.initUI(0, 0, 0, 0);
    }
}
